home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
public
/
Xprof
/
xmeasure
/
tstprops.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-08-01
|
7KB
|
322 lines
/*==================================================================
* File : tstprops.c
* Package: Xmeasure
*
* Author : Aloke Gupta.
*
* (C) Copyright 1992, Aloke Gupta.
* All rights granted to University of Illinois Board of Regents.
*==================================================================*/
#include <X11/Xatom.h>
#include "perf.h"
/* Number of subwindows for some tests */
#define SUBWINHEIGHT (DISPHEIGHT / 4)
#define SUBWINWIDTH (DISPWIDTH / 4)
/* Shared variables */
static int i;
static Window window;
/* ====================================================================== */
/* Property manipulation functions */
#define NUMPROPS 16 /* Hang 16 properties for ListProperties */
static char **atom_names;
static Atom atom;
static Atom *atom_array;
static Atom **atom_array_array;
static char *atom_string = "_Test atom for performance measurement";
int InternAtom(xd, xp)
XD *xd;
XParams *xp;
{
for (i = 0; i < xp->itns; i++)
XInternAtom(xd->display, atom_string,False);
}
int i_InternAtom(xd, xp)
XD *xd;
XParams *xp;
{ /* Nothing to initialize */ }
int c_InternAtom(xd, xp)
XD *xd;
XParams *xp;
{ /* Nothing to cleanup */ }
/* ====================================================================== */
int GetAtomName(xd, xp)
XD *xd;
XParams *xp;
{
for (i = 0; i < xp->itns; i++)
atom_names[i] = XGetAtomName(xd->display, atom);
}
int i_GetAtomName(xd, xp)
XD *xd;
XParams *xp;
{
atom_names = (char **) malloc(xp->itns * sizeof (char *));
atom = XInternAtom(xd->display, atom_string,
False);
}
int c_GetAtomName(xd, xp)
XD *xd;
XParams *xp;
{
for (i = 0; i < xp->itns; i++)
XFree(atom_names[i]);
free(atom_names);
}
/* ====================================================================== */
int ChangeProperty(xd, xp)
XD *xd;
XParams *xp;
{
Atom type = XA_ATOM;
int format = 8;
int mode = PropModeReplace;
int length;
length = strlen(atom_string);
for (i = 0; i < xp->itns; i++)
XChangeProperty(xd->display, xd->window, atom, type, format,
mode, atom_string, length);
}
int i_ChangeProperty(xd, xp)
XD *xd;
XParams *xp;
{ /* Create an atom for the atom_string */
atom = XInternAtom(xd->display, atom_string, False);
}
int c_ChangeProperty(xd, xp)
XD *xd;
XParams *xp;
{
XDeleteProperty(xd->display, xd->window, atom);
}
/* ====================================================================== */
int DeleteProperty(xd, xp)
XD *xd;
XParams *xp;
{
for (i = 0; i < xp-> itns; i ++)
XDeleteProperty(xd->display, window, atom_array[i]);
}
int i_DeleteProperty(xd, xp)
XD *xd;
XParams *xp;
{
char buffer[80];
/* Create window for hanging properties from */
window = XCreateSimpleWindow(xd->display, xd->window, 0, 0,
SUBWINWIDTH, SUBWINHEIGHT, 1, xd->foreground, xd->background);
atom_array = (Atom *) malloc (xp->itns * sizeof(Atom));
for (i = 0; i < xp-> itns; i ++) { /* Install the atoms */
sprintf(buffer, "Atom_%d", i); /* Atom_1, Atom_2, ..., etc. */
atom_array[i] = XInternAtom(xd->display, buffer, False);
/* Hang the property on the window */
XChangeProperty(xd->display, window, atom_array[i], XA_ATOM,
8, PropModeReplace, atom_string, strlen(atom_string));
}
}
int c_DeleteProperty(xd, xp)
XD *xd;
XParams *xp;
{
free(atom_array);
XDestroySubwindows(xd->display, xd->window);
}
/* ====================================================================== */
int GetProperty(xd, xp)
XD *xd;
XParams *xp;
{
Atom ret_atom;
int ret_format;
unsigned long ret_len, ret_after;
for (i = 0; i < xp-> itns; i ++)
XGetWindowProperty(xd->display, xd->window, atom, 0, 8192, False,
XA_STRING, &ret_atom, &ret_format, &ret_len, &ret_after,
&atom_names[i]);
}
int i_GetProperty(xd, xp)
XD *xd;
XParams *xp;
{
atom = XInternAtom(xd->display, atom_string, False);
atom_names = (char ** ) malloc(xp->itns * sizeof(char *));
XChangeProperty(xd->display, xd->window, atom, XA_ATOM,
8, PropModeReplace, atom_string, strlen(atom_string));
}
int c_GetProperty(xd, xp)
XD *xd;
XParams *xp;
{
for (i = 0; i < xp-> itns; i ++)
XFree(atom_names[i]);
free(atom_names);
XDeleteProperty(xd->display, xd->window, atom);
}
/* ====================================================================== */
int ListProperties(xd, xp)
XD *xd;
XParams *xp;
{
int num_props;
for (i = 0; i < xp-> itns; i ++)
atom_array_array[i] = XListProperties(xd->display, window, &num_props);
}
int i_ListProperties(xd, xp)
XD *xd;
XParams *xp;
{
char buffer[80];
atom_array = (Atom *) malloc (NUMPROPS * sizeof(Atom));
atom_array_array = (Atom **) malloc (xp->itns * sizeof(Atom *));
window = XCreateSimpleWindow(xd->display, xd->window, 0, 0,
SUBWINWIDTH, SUBWINHEIGHT, 1, xd->foreground, xd->background);
for (i = 0; i < NUMPROPS; i ++) { /* Install NUMPROPS atoms */
sprintf(buffer, "Atom_%d", i); /* Atom_1, Atom_2, ..., etc. */
atom_array[i] = XInternAtom(xd->display, buffer, False);
XChangeProperty(xd->display, window, atom_array[i], XA_ATOM, 8,
PropModeReplace, atom_string, strlen(atom_string));
}
}
int c_ListProperties(xd, xp)
XD *xd;
XParams *xp;
{
free(atom_array);
XDestroySubwindows(xd->display, xd->window);
for (i = 0; i < xp-> itns; i ++)
XFree((caddr_t) atom_array_array[i]);
free(atom_array_array);
}
/* ====================================================================== */
int SetSelectionOwner(xd, xp)
XD *xd;
XParams *xp;
{
}
int i_SetSelectionOwner(xd, xp)
XD *xd;
XParams *xp;
{
}
int c_SetSelectionOwner(xd, xp)
XD *xd;
XParams *xp;
{
}
/* ====================================================================== */
int GetSelectionOwner(xd, xp)
XD *xd;
XParams *xp;
{
}
int i_GetSelectionOwner(xd, xp)
XD *xd;
XParams *xp;
{
}
int c_GetSelectionOwner(xd, xp)
XD *xd;
XParams *xp;
{
}
/* ====================================================================== */
int ConvertSelection(xd, xp)
XD *xd;
XParams *xp;
{
}
int i_ConvertSelection(xd, xp)
XD *xd;
XParams *xp;
{
}
int c_ConvertSelection(xd, xp)
XD *xd;
XParams *xp;
{
}
/* ====================================================================== */
int RotateProperties(xd, xp)
XD *xd;
XParams *xp;
{
for (i = 0; i < xp-> itns; i ++)
XRotateWindowProperties(xd->display, window, atom_array,
NUMPROPS, NUMPROPS / 2);
}
int i_RotateProperties(xd, xp)
XD *xd;
XParams *xp;
{
char buffer[80];
atom_array = (Atom *) malloc (NUMPROPS * sizeof(Atom));
window = XCreateSimpleWindow(xd->display, xd->window, 0, 0,
SUBWINWIDTH, SUBWINHEIGHT, 1, xd->foreground, xd->background);
for (i = 0; i < NUMPROPS; i ++) { /* Install NUMPROPS atoms */
sprintf(buffer, "Atom_%d", i); /* Atom_1, Atom_2, ..., etc. */
atom_array[i] = XInternAtom(xd->display, buffer, False);
XChangeProperty(xd->display, window, atom_array[i], XA_ATOM, 8,
PropModeReplace, atom_string, strlen(atom_string));
}
}
int c_RotateProperties(xd, xp)
XD *xd;
XParams *xp;
{
free(atom_array);
XDestroySubwindows(xd->display, xd->window);
}